#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll rr() {
    ll s = 0, w = false, c = getchar();
    for (; !isdigit(c); c = getchar())
        w = w || c == '-';
    for (; isdigit(c); c = getchar())
        s = s * 10 + c - '0';
    return w ? -s : s;
}

// END OF HEADER

int main() {
    int N, M;
    cin >> N >> M;
    while (N--) {
        string s;
        cin >> s;
        int stk = 0;
        bool flag = false;
        for (auto c : s) {
            if (c == 'S')
                stk++;
            else
                stk--;
            if (stk < 0 || stk > M)
                flag = true;
        }
        if (flag || stk != 0)
            cout << "NO\n";
        else
            cout << "YES\n";
    }
    return 0;
}
